<?php

namespace app\controller;

use EasyWeChat\Factory;
use think\facade\Config;

class Wechat
{
    private $app;

    public function __construct()
    {
        Config::load('snake/wechat', 'wechat');
        $this->app = Factory::officialAccount(get_wechat_config());
    }

    public function __destruct()
    {
        unset(
            $this->app
        );
    }

    public function checkServerSign()
    {
        return $this->app->server->serve();
    }

    public function sendServerMenu()
    {
        record_log('更新了微信公众号菜单');
        return $this->app->menu->create(config('wechat.menu_data'));
    }
}